﻿using System;
using System.Collections.Generic;
using System.Text;
using He.Common;

namespace He.Web.UI
{
    public partial class PageBase
    {
        private static Model.webset _webset;
        private string _langxmlpath = "~/config/lang.config";
        private string _plugxmlpath = "~/config/plug.config";
        private string _uploadimgext = "BMP|JPEG|JPG|GIF|PNG";
        private bool _showwx = false;
        private string _lastlisturl = "";
        private string _sitedomain = "";
        private string _siteurl = "";
        private string _wxlang = "mobile";
        private string _currentlang = "";

        /// <summary>
        /// 网站配置
        /// </summary>
        public static Model.webset webset
        {
            set
            {
                _webset = value;
            }
            get
            {
                return new BLL.webset().GetWebset();
            }
        }


        /// <summary>
        /// 语言模块xml路径
        /// </summary>
        public string LangXmlPath
        {
            set
            {
                _langxmlpath = value;
            }
            get
            {
                return _langxmlpath;
            }
        }

        /// <summary>
        /// 插件xml路径
        /// </summary>
        public string PlugXmlPath
        {
            set
            {
                _plugxmlpath = value;
            }
            get
            {
                return _plugxmlpath;
            }
        }

        /// <summary>
        /// 允许上传的文件格式
        /// </summary>
        public string UploadImgExt
        {
            set { _uploadimgext = value; }
            get { return _uploadimgext; }
        }

        /// <summary>
        /// 是否开启微信
        /// </summary>
        public bool ShowWx
        {
            set
            {
                _showwx = value;
            }
            get
            {
                if (webset.wx_status == (int)Enums.Status.开启)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
        }

        /// <summary>
        /// 上次浏览的列表页
        /// </summary>
        public string LastListUrl
        {
            set
            {
                _lastlisturl = value;
            }
            get
            {
                string url = CookieHelper.Get(SysKeys.LAST_LIST_URL_COOKIE_NAME);
                if (string.IsNullOrEmpty(url))
                {
                    url = Request.RawUrl;
                }
                return url;
            }
        }

        /// <summary>
        /// 网站域名
        /// </summary>
        public string SiteDomain
        {
            set
            {
                _sitedomain = value;
            }
            get
            {
                return webset.site_domain.Replace("http://", "").Trim('/');
            }
        }

        /// <summary>
        /// 网站URL
        /// </summary>
        public string SiteUrl
        {
            set
            {
                _siteurl = value;
            }
            get
            {
                return string.Format("http://{0}", SiteDomain);
            }
        }

        /// <summary>
        /// 微信绑定语言版本
        /// </summary>
        //public string WxLang
        //{
        //    set
        //    {
        //        _wxlang = value;
        //    }
        //    get
        //    {
        //        return _wxlang;
        //    }
        //}

        /// <summary>
        /// 当前语言版本
        /// </summary>
        public string CurrentLang
        {
            set
            {
                _currentlang = value;
            }
            get
            {
                string lang = CookieHelper.Get(SysKeys.CURRENT_LANG_COOKIE_NAME);
                if (string.IsNullOrEmpty(lang))
                {
                    lang = "cn";
                }
                return lang;
            }
        }
    }
}
